<template>
	<view class="back-view">
		<view class="view-background"></view>
		<view class="white-view-back">
			<view class="top-back">
				<view class="top-name">咨询详情</view>
				<view class="close-back" @click="closeBtnAction">
					<image class="close-img" src="../../../static/close.png"></image>
				</view>
			</view>
			<view class="top-line"></view>
			<view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">编号</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.no}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">客户名称</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.custName}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">咨询领域</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.domainDict}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">希望我们</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.hopeDict}}</view>
				</view>
				<view class="item-back ">
					<view style="display: flex;">
						<view class="item-name">咨询内容</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.content}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">咨询文件</view>
						<view class="item-name-des">:</view>
					</view>
					<view>
						<view v-for="(item,index) in attachFile" :key="index">
							<view style="display: flex; align-items: center;"
								v-if="item.fileSuffix !='aac' && item.fileSuffix!='m4a'">
								<image src="../../../static/phone/jpg.png" class="item-img"
									v-if="item.fileSuffix =='jpg' || item.fileSuffix=='png'"></image>
								<image src="../../../static/phone/case-detail-excel.png" class="item-img"
									v-if="item.fileSuffix =='xls' || item.fileSuffix=='xlsx'"></image>
								<image src="../../../static/phone/case-detail-word.png" class="item-img"
									v-if="item.fileSuffix =='docx' || item.fileSuffix=='doc'"></image>
								<image src="../../../static/phone/case-detail-ppt.png" class="item-img"
									v-if="item.fileSuffix =='pptx' || item.fileSuffix=='ppt'"></image>
								<image src="../../../static/phone/case-detail-pdf.png" class="item-img"
									v-if="item.fileSuffix =='pdf' || item.fileSuffix=='pdfx'"></image>
								<view class="item-file-name">{{item.name}}</view>
							</view>
						</view>
					</view>

				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">发起时间</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.createTime}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">发起人</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.createAt}}</view>
				</view>
				<view class="item-back">
					<view style="display: flex;">
						<view class="item-name">状 态</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.status.desc}}</view>
				</view>
				<view class="item-back" v-if="itemDetail.status.code == '7' || itemDetail.status.code == '8'">
					<view style="display: flex;">
						<view class="item-name">原 因</view>
						<view class="item-name-des">:</view>
					</view>
					<view class="item-content">{{itemDetail.failMsg}}</view>
				</view>
			</view>
			<view class="bottom-back" v-if="btnTitle">
				<view class="bottom-btn" @click="btnAction">{{btnTitle}}</view>
			</view>
		</view>
		<check v-on:successBack='updataRequest()' :itemID='itemDetail.id' v-if="showCheck"
			@checkClose='clickCheckClose'></check>
		<caseDistribute v-if="showDistribute" :selectItem='itemDetail' v-on:successBack='updataRequest()'
			@clickDistributeClose='clickDistributeClose'></caseDistribute>
	</view>
</template>

<script>
	import check from "@/packageC/PhonePC/caseManage/check.vue"
	import caseDistribute from "@/packageC/PhonePC/caseManage/caseDistribute.vue"

	export default {
		components: {
			check,
			caseDistribute
		},
		props: {
			selectItem: {
				type: Object,
				default: {}
			},
			editType: {
				type: String,
				default: 'add',
			},

		},
		data() {
			return {
				itemDetail: {},
				desc: '',
				attachFile: [],
				btnTitle: '编辑',
				showCheck: false,
				showDistribute: false,
				itemID: ''
			}
		},
		mounted() {
			this.getDetail()
		},
		methods: {
			async updataRequest() {
				this.getDetail()
				this.$emit("successBack");
			},
			async getDetail() {
				let _this = this
				const res = await _this.$myRequest({
					url: "/admin/case/" + _this.selectItem.id,
					method: 'GET', //默认是GET
				})
				console.log('详情', res)
				if (res.data.code == 200) {
					_this.itemDetail = res.data.data
					if (res.data.data.attachFile) {
						_this.attachFile = res.data.data.attachFile
					}
					_this.desc = _this.itemDetail.status.desc
					if (_this.desc == '待提交') {
						_this.btnTitle = '编辑'
					} else if (_this.desc == '待审核') {
						_this.btnTitle = '审核'
					} else if (_this.desc == '待分配') {
						_this.btnTitle = '分配'
					} else if (_this.desc == '审核不通过' || _this.desc == '异常终止') {
						_this.btnTitle = '重新发起'

					} else {
						_this.btnTitle = ''
					}
				}
			},

			btnAction() {
				if (this.btnTitle == '编辑') {

				} else if (this.btnTitle == '审核') {
					this.showCheck = true;
				} else if (this.btnTitle == '分配') {
					this.showDistribute = true;
				} else if (this.btnTitle == '重新发起') {

				}
			},

			clickCheckClose() {
				this.showCheck = false;
			},

			clickDistributeClose() {
				this.showDistribute = false;
			},
			closeBtnAction() {
				this.$emit('consultClose')
			}
		},
	}
</script>

<style>
	.back-view {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 9999;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.view-background {
		position: absolute;
		width: 100%;
		height: 100%;
		z-index: -1;
		background-color: rgba(0, 0, 0, 0.3);
	}

	.white-view-back {
		width: 60%;
		padding: 24px;
		max-height: 80%;
		background-color: white;
		margin-top: -70px;
		border-radius: 4px;
	}

	.top-back {
		display: flex;
		justify-content: space-between;
	}

	.top-name {
		font-size: 18px;
		font-weight: normal;
		color: #333333;

	}

	.close-back {
		cursor: pointer;
		width: 20px;
		height: 20px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.close-img {
		width: 12px;
		height: 12px;
	}

	.top-line {
		height: 1px;
		background: #EEEEEE;
		width: 100%;
		margin-top: 20px;
		margin-bottom: 20px;
	}

	.item-back {
		display: flex;
		align-items: flex-start;
		margin-bottom: 10px;
	}


	.item-name {
		font-size: 14px;
		font-weight: 400;
		color: #999999;
		width: 60px;
		min-width: 60px;
		text-align: justify;
		text-align-last: justify;
		display: inline-block;
	}

	.item-name-des {

		font-size: 14px;
		font-weight: 400;
		color: #999999;
		margin-right: 16px;
	}

	.item-file-name {
		font-size: 12px;
		font-weight: 400;
		color: #333333;
	}

	.item-content {
		font-size: 14px;
		font-weight: 400;
		color: #333333;
	}

	.item-img {
		width: 24px;
		height: 24px;
		min-width: 24px;
		margin-right: 8px;
	}

	.bottom-back {
		margin-top: 10px;
		width: 100%;
		min-height: 30px;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.bottom-btn {
		cursor: pointer;
		width: 104px;
		height: 32px;
		background: #2DA9C5;
		border-radius: 2px;
		color: #FFFFFF;
		font-size: 14px;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>